package com.wsx.ones.cloud.product;

import com.wsx.ones.cloud.AbstractBaseController;
import org.springframework.web.bind.annotation.*;

/**
 * Created by wangshuaixin on 17/5/16.
 */
@RestController
@RequestMapping("/product")
public class ProductController extends AbstractBaseController {

    @RequestMapping(
            value = "/save",
            method = {RequestMethod.POST}
    )
    public String saveProduct(Product product) {
        StringBuilder builder = new StringBuilder();
        builder.append(product.getId());
        builder.append("--");
        builder.append(product.getName());

        return builder.toString();
    }


    @RequestMapping(
            value = "/get",
            method = {RequestMethod.GET}
    )
    public String getProduct(@RequestParam("id") Integer id) {
        StringBuilder builder = new StringBuilder();
        builder.append(id);
        builder.append("--==");
        return builder.toString();
    }

    @RequestMapping(
            value = "/second",
            method = {RequestMethod.POST}
    )
    public String second(@RequestBody Product product) {
        StringBuilder builder = new StringBuilder();

        builder.append(product.getId());
        builder.append("==");
        builder.append(product.getName());
        return builder.toString();
    }
}
